package edu.ynu.se.xiecheng.achitectureclass.dto;

import edu.ynu.se.xiecheng.achitectureclass.entity.Statistic;
import lombok.Getter;
import lombok.Setter;

import java.util.Base64;
import java.util.Date;

@Getter
@Setter
public class StatisticObject {

    private String statisticName;
    private Long statisticValue;
    private String statisticPhoto;
    private Date createTime;

    public StatisticObject(Statistic statistic) {
        this.statisticName = statistic.getStatisticName();
        this.statisticValue = statistic.getStatisticValue();
        if (statistic.getStatisticPhoto() != null) {
            this.statisticPhoto = Base64.getEncoder().encodeToString(statistic.getStatisticPhoto());
        } else {
            this.statisticPhoto = "";
        }
        this.createTime = statistic.getCreateTime();
    }
}
